import abc

from typing import List, Optional

from pymongo import UpdateOne

from src.basedata.domain.po import ApplicationMedicineLibraryMapPO, MedicineLibraryPO, MedicineLibraryListPO, KnowledgeICD10MappingPO,\
    AppFreqMappingPO, AppAdministrationMappingPO, DepartmentPO, PersonPO
from src.seedwork.domain.entities import PyObjectId


class AppConfigAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def get_basedata_sync_config(self, app_id: Optional[str]):
        raise NotImplementedError

    @abc.abstractmethod
    async def get_xhhk_encrypt_config(self, app_id):
        raise NotImplementedError


class AppFreqMappingAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[AppFreqMappingPO]):
        raise NotImplementedError


class AppAdministrationMappingAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[AppAdministrationMappingPO]):
        raise NotImplementedError


class KnowledgeICD10MappingAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[KnowledgeICD10MappingPO]):
        raise NotImplementedError


class DepartmentAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[DepartmentPO]):
        raise NotImplementedError

    @abc.abstractmethod
    async def batch_update(self, data: List[UpdateOne]):
        raise NotImplementedError

    @abc.abstractmethod
    async def get_data_by_codes(self, app_id: str, codes: List[str]):
        raise NotImplementedError


class PersonAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[PersonPO]):
        raise NotImplementedError

    @abc.abstractmethod
    async def save_data_to_redis(self, app_code: str, data: List[PersonPO]):
        raise NotImplementedError


class MedicineLibraryAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[UpdateOne]):
        raise NotImplementedError

    @abc.abstractmethod
    async def add(self, data: MedicineLibraryPO) -> str:
        raise NotImplementedError


class MedicineLibraryListAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[MedicineLibraryListPO]):
        raise NotImplementedError

    @abc.abstractmethod
    async def get_by_codes(self, library_id: str, codes: List[str]):
        raise NotImplementedError

    @abc.abstractmethod
    async def save_data_to_redis(self, library_id, data: List[MedicineLibraryListPO]):
        raise NotImplementedError


class AppMedicineLibraryMappingAbstractRepository(abc.ABC):
    def __init__(self):
        pass

    @abc.abstractmethod
    async def batch_save(self, data: List[UpdateOne]):
        raise NotImplementedError

    @abc.abstractmethod
    async def get_by_app_id(self, app_id: str):
        raise NotImplementedError

    @abc.abstractmethod
    async def add(self, data: ApplicationMedicineLibraryMapPO) -> str:
        raise NotImplementedError
